package com.xt.utils;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

/**
 * Created by XT on 2018/5/5.
 */
public class PageUtil {

    public static Pageable getPageable(int count, int pageNo, String sortDirection, String[] sortField) {
        Sort sort = null;
        if ("asc".equalsIgnoreCase(sortDirection)) {
            sort = new Sort(Sort.Direction.ASC, sortField);
        } else {
            sort = new Sort(Sort.Direction.DESC, sortField);
        }
        //设置分页
        return new PageRequest(pageNo, count, sort);
    }

}
